package net.wanho.controller;

import lombok.RequiredArgsConstructor;
import net.wanho.R.R;
import net.wanho.dto.InStoreConfirmDTO;
import net.wanho.dto.InStoreDTO;
import net.wanho.dto.InStoreExportDTO;
import net.wanho.service.InStoreService;
import net.wanho.vo.InStoreExportVO;
import net.wanho.vo.InStoreVO;
import net.wanho.vo.PageInfo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 这个类是：
 *
 * @author: MENG HU WANG
 * @date: 2025/2/6 12:48
 * @version: 1.0
 */

@RestController
@RequiredArgsConstructor
@RequestMapping("instore")
public class InStoreController {

    private final InStoreService inStoreService;

    // 分页查询
    @RequestMapping("instore-page-list")
    public R getInStorePageList(@RequestParam(defaultValue = "1") Integer pageNum,
                                @RequestParam(defaultValue = "5") Integer pageSize,
                                InStoreDTO inStoreDTO) {
        PageInfo<InStoreVO> inStorePageList = inStoreService.getInStorePageList(pageNum, pageSize, inStoreDTO);
        return R.ok(inStorePageList);
    }

    // 确认入库
    @PutMapping("instore-confirm")
    public R confirmInStore(@RequestBody InStoreConfirmDTO inStoreConfirmDTO) {
        inStoreService.updateInStoreIsIn(inStoreConfirmDTO);
        return R.ok("入库成功");
    }

    // 导出数据
    @GetMapping("exportTable")
    public R exportTable(@RequestParam(defaultValue = "1") Integer pageNum,
                         @RequestParam(defaultValue = "5") Integer pageSize,
                         InStoreExportDTO inStoreExportDTO) {
        List<InStoreExportVO> list = inStoreService.exportTable(pageNum, pageSize, inStoreExportDTO);
        return R.ok(list);
    }
}
